import okhttp3.*;

import java.io.File;
import java.io.IOException;

/**
 * Created by zhangbn on 2018/11/12.
 */
public class GetFeature {

    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();

        File file = new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\刘德华1.jpg");
        RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);

        RequestBody requestBody = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("imageData", "imageData", fileBody)
//                .addFormDataPart("imagetype", "png")
                .build();

        Request request = new Request.Builder()
                .url("http://10.82.25.181:9001/verify/feature/gets")
                .post(requestBody)
                .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());


//        String str = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"imageData\"; filename=\"C:\\Users\\Public\\Pictures\\Sample Pictures\\刘德华" +
//                ".jpg\"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"abc\"\r\n\r\nxyz\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";
//
//        System.out.println(str);
    }
}
